import {baseUrl} from "@/config/env";
import userApi from "@/api/sys/userApi";
import userOption from "@/option/sys/userOption";
import optionUtils from "@/option/optionUtils";


export default () => {
    return {
        index: true,
        submitText: '修改',
        size: 'small',
        labelWidth: 100,
        menuAlign: 'center',
        menuPosition: "right",
        column: [
            {
                label: '管理机构',
                prop: 'deptId',
                span: 12,
                type: "tree",
                dicUrl: baseUrl + "/start/sysDept/listTree",
                props: {
                    label: "name",
                    value: "id",
                },
                showColumn: true,
            },
            {
                label: '用户名',
                span: 12,
                prop: 'userId',
                type: "table",
                props: {
                    label: 'userName',
                    value: 'id'
                },
                children: userOption(),
                onLoad: (onLoadParams, callback) => {
                    onLoadParams.pageDefinition = userApi.list
                    onLoadParams.valueDefinition = userApi.getUserInfo
                    onLoadParams.option = userOption;
                    optionUtils.tableOnLoad(onLoadParams, callback)
                },
                formatter: (row) => {
                    if (!row) return;
                    if (row.nickName) {
                        return row.nickName;
                    } else if (row.realName) {
                        return row.realName
                    }
                    return row.userName;
                }
            },
            {
                label: '管理级别',
                span: 12,
                prop: 'manageLevel',
                type: "select",
                dicUrl: baseUrl + "/start/sysDictionaryItem/listByDictionaryCode",
                dicMethod: "get",
                dicQuery: {code: "user_manage_dept_levels"},
                props: {
                    label: 'name',
                    value: 'dictionaryValue',
                },
            },
            {
                label: '序号',
                prop: 'sort',
                type: "number",
                span: 12,
            },

        ]
    }
}
